package com.qys.livesMall.file.server.upload.config;

import com.qys.livesMall.file.server.upload.service.UploadFileService;
import com.qys.livesMall.file.server.upload.service.impl.local.LocalUploadFileServiceImpl;
import com.qys.livesMall.file.server.upload.service.impl.oss.OssUploadFileServiceImpl;
import jakarta.annotation.PostConstruct;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by IntelliJ IDEA.
 * User: dp
 * Date: 2023/05/19
 * Time: 14:56
 * DESCRIPTION:
 */
@Configuration
@Data
public class UploadConfig {

    @Value("${upload.oss}")
    private boolean ossUpload;

    public static boolean isOss;

    @PostConstruct
    public void init() {
        isOss = this.ossUpload;
    }

    @Bean
    public UploadFileService uploadFileService() {
        return ossUpload ? new OssUploadFileServiceImpl() : new LocalUploadFileServiceImpl();
    }
}
